package cz.muni.fi.pa165.travelagency.persistence;

import cz.muni.fi.pa165.travelagency.entities.Customer;
import java.util.List;

/**
 * @author Jan Novotný
 * @version 1.0
 * @created 11-10-2012 15:39:17
 */
public interface ICustomerDAO {

    /**
     * saves customer into a persistent repository
     * @param customer that should be saved
     * @throws IllegalArgumentException if customer is null
     * @throws IllegalArgumentException if Customer.name is null
     * @throws IllegalArgumentException if Customer.address is null
     * @throws IllegalArgumentException if Customer.phoneNumber is null
     * @throws IllegalArgumentException if Customer.phoneNumber longer than 12 characters
     * @throws IllegalStateException if customer is already created/saved
     */
    public void createCustomer(Customer customer);

    /**
     * deletes customer from a persistent repository, 
     * doesn't do anything if customer was´already deleted
     * @param customer for removal
     * @throws IllegalArgumentException if customer is null
     * @throws IllegalStateException if customer wasn't saved yet
     */
    public void deleteCustomer(Customer customer);

    /**
     * returns all customers from a persistent repository
     * @return all customers or empty list if there are no customers
     */
    public List<Customer> findAll();

    /**
     * returns all customers whose name contains specified string,
     * search strategy is LIKE %name%
     * @param name string which must be contained in a customer's name
     * @return all customers whose name matches given string or empty list if there is no match
     * @throws IllegalArgumentException if name is null
     */
    public List<Customer> findByName(String name);

    /**
     * returns a customer with given id
     * @param id of a customer
     * @return customer or null if customer of given id wasn't found
     * @throws IllegalArgumentException if id is null
     */
    public Customer getCustomer(Long id);

    /**
     * saves all changes done to given customer to a persistent repository
     * @param customer to update
     * @throws IllegalArgumentException if customer is null
     * @throws IllegalArgumentException if Customer.name is null
     * @throws IllegalArgumentException if Customer.address is null
     * @throws IllegalArgumentException if Customer.phoneNumber is null 
     * @throws IllegalArgumentException if Customer.phoneNumber longer than 12 characters
     * @throws IllegalStateException if customer wasn't saved yet
     */
    public void updateCustomer(Customer customer);
}